local lhs "cog"
local rhs "hours"
local robust "simple"
local controls "${CONTROLlist_`lhs'_wage}"
local subsample  "$subsample"
local type "het2"

qui {
	local cnt=100
	capture program drop ccn_het2
	matrix actual_estimates_mat = J(`cnt',8,-9)
	local rowcounter = 0
	forvalues K=1(1)100 {
		noisily display "LHS=`lhs', RHS=`rhs', SE=`robust', K=`K', $S_DATE, $S_TIME"
		local rowcounter = `rowcounter'+1
		use "$datapath/003_cluster_`subsample'_`lhs'.dta", clear		
		qui tab X_`K', generate(dumX_`K'_)
		gen A=afqt_mom
		gen W=wage_mom_r
		qui ccn_`type' symmetric `K' `rhs' `lhs' `robust' "`controls'" het_tobit
		matrix actual_estimates_mat[`rowcounter',1] = r(BETA)
		matrix actual_estimates_mat[`rowcounter',2] = r(BETA_se)		
		matrix actual_estimates_mat[`rowcounter',3] = r(BETA_A)
		matrix actual_estimates_mat[`rowcounter',4] = r(BETA_A_se)		
		matrix actual_estimates_mat[`rowcounter',5] = r(BETA_W)
		matrix actual_estimates_mat[`rowcounter',6] = r(BETA_W_se)		
		matrix actual_estimates_mat[`rowcounter',7] = r(ESAMP)
		matrix actual_estimates_mat[`rowcounter',8] = `K'
	}
}
mat colnames actual_estimates_mat = b_HetSymm se_HetSymm bA_HetSymm seA_HetSymm bW_HetSymm seW_HetSymm Neff_HetSymm Kcluster
clear
qui svmat actual_estimates_mat, names(col)
gen LHS="`lhs'"
gen RHS="`rhs'"
replace b_HetSymm=100*b_HetSymm
replace se_HetSymm=100*se_HetSymm
replace bA_HetSymm=100*bA_HetSymm
replace seA_HetSymm=100*seA_HetSymm
replace bW_HetSymm=100*bW_HetSymm
replace seW_HetSymm=100*seW_HetSym
save "$datapath/000_`type'_byK.dta", replace
